/*
 * CMediaPlayer.cpp
 *
 *  Created on: 2018年8月2日
 *      Author: zhengboyuan
 */

#include "stdafx.h"
#include "CMediaPlayer.h"

CMediaPlayer::CMediaPlayer()
{
}

CMediaPlayer::~CMediaPlayer()
{
    Close();
}

void CMediaPlayer::Close()
{
    if (IsOpen())
    {
        Stop();
    }
}

bool CMediaPlayer::IsOpen()
{
    return m_url.size() > 0;
}

void CMediaPlayer::Stop()
{
    MDecode_Stop(m_handle);

    m_url.clear();
}

bool CMediaPlayer::Open(const char* url, const char* params)
{
    if (!url)
    {
        return false;
    }

    m_url = url;

    BOOL ret = MDecode_OpenFileEx(m_handle, url, params);

	onOpen();

    return (ret > 0);
}

std::string CMediaPlayer::GetUrl()
{
    return m_url;
}
